import 'dart:ffi';

import 'package:flutter/material.dart';

class Cell extends StatelessWidget {
  const Cell({
    Key? key,
    required this.title,
    this.value,
    this.islink,
    this.rightIcon,
  }) : super(key: key);
  final String title;
  final String? value;
  final bool? islink;
  final Widget? rightIcon;
  @override
  Widget build(BuildContext context) {
    List<Widget> children = [Text(title)];

    List<Widget> rightChildren = [];
    if ((value ?? "").isNotEmpty) {
      rightChildren.add(Text(value ?? ""));
    }
    if ((islink ?? false) == true) {
      rightChildren.add(const Icon(Icons.arrow_forward_ios_rounded));
    }
    if (rightIcon != null) {
      if ((islink ?? false) == true) {
        rightChildren.removeLast();
      }
      rightChildren.add(rightIcon!);
    }
    if (rightChildren.isNotEmpty) {
      children.add(Row(
        children: rightChildren,
      ));
    }
    return Container(
      padding: const EdgeInsets.all(12),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: children,
      ),
    );
  }
}
